﻿


//订单检查
//isAccount:true 是否是从账单过来的
function isPayCheck(settleId, isAccount) {
    //settleId = "200000000616";
    //加载层
    layer.load(0, { shade: [0.3, '#000'] });
    $.ajax({
        url: "../Home/PayPaidQuery",
        type: "post",
        data: { settlementId: settleId },
        success: function (obj) {
            layer.closeAll();
            if (obj != "" && $.parseJSON(obj).Flag == 2) {
                //弹出支付成功层
                showSuccessDialog();
                //从账单过来改变数据行数据，未支付变已支付，去支付按钮变已支付
                if(isAccount) {
                    $("#statusTit_" + settleId).html("<span>已付款</span>");
                    $("#statusBtn_" + settleId).html("<span class=\"AccountpageGrey\">已付款</span>");
                }
            } else {
                $("#btnSuc").hide();
                $("#btnRes").css("display", "block");
                $("#UnsuccessfulPrompt").show();
               //layer.alert("暂未查询到结果，请稍候再试");
            }
        }
    });
}


//关闭支付弹层
function ClosePay() {
    $(".pay_bg").hide();
    $(".pay_mainBox").hide();
}
//打开支付弹层
function OpenPay() {
    $(".pay_bg").show();
    $(".pay_mainBox").show();
}

//弹出第二个层
function goPayShowDialog() {
    ClosePay();
    $(".pay_bg").show();
    //如果第一次点击打开
    if ($(".payConfirmBox").css("display") === 'none') {
        timeCounter('countTime', 0);
    } else {
        //点击重新支付
        timeCounter('countTime', 1);

    };
    $(".payConfirmBox").show();
}

//关闭弹窗第二层
function ClosePay2() {
    $(".pay_bg").hide();
    $(".payConfirmBox").hide();
}

//弹出第三个层
function showSuccessDialog() {
    ClosePay2();
    $(".pay_bg").show();
    $(".paySusscesBox").show();
}

//关闭弹窗第三层
function ClosePay3() {
    $(".pay_bg").hide();
    $(".paySusscesBox").hide();
}


//倒计时
var isbegin = 0;
var timeCounter = (function() {
    var int;
    var total = 1800;
    return function(elemID, type) {
        obj = document.getElementById(elemID);
        if (type == 0) {
            var s = (total % 60) < 10 ? ('0' + total % 60) : total % 60;
            var h = total / 3600 < 10 ? ('0' + parseInt(total / 3600)) : parseInt(total / 3600);
            var m = (total - h * 3600) / 60 < 10 ? ('0' + parseInt((total - h * 3600) / 60)) : parseInt((total - h * 3600) / 60);
            obj.innerHTML = m + '分' + s + '秒';
            total--;
            int = setTimeout("timeCounter('" + elemID + "',0)", 1000);
            if (total < 0) clearTimeout(int);
        } else if (type == 1) {
            clearTimeout(int);
            total = 1800;
            timeCounter(elemID, 0);
        }
    };
})();
